package jeye.processor;

import java.awt.Component;
import java.io.IOException;

import javax.media.ClockStoppedException;
import javax.media.Control;
import javax.media.Controller;
import javax.media.ControllerListener;
import javax.media.GainControl;
import javax.media.IncompatibleSourceException;
import javax.media.IncompatibleTimeBaseException;
import javax.media.NotConfiguredError;
import javax.media.NotRealizedError;
import javax.media.Processor;
import javax.media.Time;
import javax.media.TimeBase;
import javax.media.UnsupportedPlugInException;
import javax.media.control.TrackControl;
import javax.media.format.VideoFormat;
import javax.media.protocol.ContentDescriptor;
import javax.media.protocol.DataSource;

import jeye.effects.VideoEffect;

public class JEyeProcessor implements Processor {

	private Processor processorInstance;
	
	public JEyeProcessor(Processor processorInstance) {
		this.processorInstance = processorInstance;
	}
	
	public void setVideoEffects(VideoEffect[] videoEffects) throws UnsupportedPlugInException, NotConfiguredError {
		for(TrackControl trackControl : getTrackControls()) {
			if(trackControl.getFormat() instanceof VideoFormat) {
				trackControl.setCodecChain(videoEffects);
			}
		}
	}
	
	public void addController(Controller controller) throws IncompatibleTimeBaseException {
		processorInstance.addController(controller);
	}

	public void addControllerListener(ControllerListener controllerListener) {
		processorInstance.addControllerListener(controllerListener);
	}

	public void close() {
		processorInstance.close();
	}

	public void configure() {
		processorInstance.configure();
	}

	public void deallocate() {
		processorInstance.deallocate();
	}

	public ContentDescriptor getContentDescriptor() throws NotConfiguredError {
		return processorInstance.getContentDescriptor();
	}

	public Control getControl(String arg0) {
		return processorInstance.getControl(arg0);
	}

	public Component getControlPanelComponent() {
		return processorInstance.getControlPanelComponent();
	}

	public Control[] getControls() {
		return processorInstance.getControls();
	}

	public DataSource getDataOutput() throws NotRealizedError {
		return processorInstance.getDataOutput();
	}

	public Time getDuration() {
		return processorInstance.getDuration();
	}

	public GainControl getGainControl() {
		return processorInstance.getGainControl();
	}

	public long getMediaNanoseconds() {
		return processorInstance.getMediaNanoseconds();
	}

	public Time getMediaTime() {
		return processorInstance.getMediaTime();
	}

	public float getRate() {
		return processorInstance.getRate();
	}

	public Time getStartLatency() {
		return processorInstance.getStartLatency();
	}

	public int getState() {
		return processorInstance.getState();
	}

	public Time getStopTime() {
		return processorInstance.getStopTime();
	}

	public ContentDescriptor[] getSupportedContentDescriptors() throws NotConfiguredError {
		return processorInstance.getSupportedContentDescriptors();
	}

	public Time getSyncTime() {
		return processorInstance.getSyncTime();
	}

	public int getTargetState() {
		return processorInstance.getTargetState();
	}

	public TimeBase getTimeBase() {
		return processorInstance.getTimeBase();
	}

	public TrackControl[] getTrackControls() throws NotConfiguredError {
		return processorInstance.getTrackControls();
	}

	public Component getVisualComponent() {
		return processorInstance.getVisualComponent();
	}

	public Time mapToTimeBase(Time arg0) throws ClockStoppedException {
		return processorInstance.mapToTimeBase(arg0);
	}

	public void prefetch() {
		processorInstance.prefetch();
	}

	public void realize() {
		processorInstance.realize();
	}

	public void removeController(Controller arg0) {
		processorInstance.removeController(arg0);
	}

	public void removeControllerListener(ControllerListener arg0) {
		processorInstance.removeControllerListener(arg0);
	}

	public ContentDescriptor setContentDescriptor(ContentDescriptor arg0) throws NotConfiguredError {
		return processorInstance.setContentDescriptor(arg0);
	}

	public void setMediaTime(Time arg0) {
		processorInstance.setMediaTime(arg0);
	}

	public float setRate(float arg0) {
		return processorInstance.setRate(arg0);
	}

	public void setSource(DataSource arg0) throws IOException, IncompatibleSourceException {
		processorInstance.setSource(arg0);
	}

	public void setStopTime(Time arg0) {
		processorInstance.setStopTime(arg0);
	}

	public void setTimeBase(TimeBase arg0) throws IncompatibleTimeBaseException {
		processorInstance.setTimeBase(arg0);
	}

	public void start() {
		processorInstance.start();
	}

	public void stop() {
		processorInstance.stop();
	}

	public void syncStart(Time arg0) {
		processorInstance.syncStart(arg0);
	}
}
